/*
 * btn.c
 *
 *  Created on: Apr 8, 2013
 *      Author: Vincent
 */

#include "support_common.h" /* include peripheral declarations and more */
#include <stdio.h>
#include "pushb.h"
#include "ledmat.h"
#include "pit0.h"



//int mode;

void gpt_init()
{
        MCF_GPIO_PTAPAR |= 0x01;
        MCF_GPT_GPTIOS = 0x00;
        MCF_GPT_GPTCTL2 = 0x01;
        MCF_GPT_GPTDDR = 0x00;
        MCF_GPT_GPTIE = 0x01;
        MCF_GPT_GPTSCR1 = 0x80;
        int_config(44,1,7,gpt0_isr);
        MCF_GPT_GPTFLG1 = 0x0F ;
}


__declspec(interrupt) void gpt0_isr()
{

	 MCF_GPT_GPTFLG1 = 0x0F; 
	 mode = 1;

		 
	 /*else if (mode ==2)
	 {
		 mode = 0;
	 	 ledmat_off();
	 } */
	 
	 //while(mode>0)
	 //{ledmat_off();}
		
}

/*-----------------------------------------------------------
FUNCTION: gpt0_isr()
NOTES: 1.  The __declspec(interrupt) specifier tells the C compiler that this is not just any odd function, but rather is an ISR.
2. ISR's must return by performing the RTE instruction, whereas regular functions return by
performing an RTS instruction.
3. Regular functions can use scratch registers d0-d2 and a0-a2 without saving them. On the other hand, IRS's are not permitted to use ANY registers, including scratch registers without saving them.
-----------------------------------------------------------*/


